package o;

import android.app.Activity;
import android.os.Build.VERSION;

public class ccg {
    public static void ˊ(cci o_cci, int i, String[] strArr, int[] iArr) {
        if (iArr == null || iArr.length == 0) {
            o_cci.ˊ(i, -1);
            return;
        }
        for (int i2 : iArr) {
            if (i2 == -1) {
                o_cci.ˊ(i, -1);
                return;
            }
        }
        o_cci.ˊ(i, 0);
    }

    public static String[] ˎ(int i) {
        if (i == 22 || i == 24) {
            return new String[]{"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};
        } else if (i == 23) {
            return new String[]{"android.permission.READ_PHONE_STATE"};
        } else if (i != 21) {
            return null;
        } else {
            return new String[]{"android.permission.CAMERA", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};
        }
    }

    public static boolean ॱ(Activity activity, int i) {
        return ˊ(ˎ(i), activity, true, i);
    }

    private static boolean ˊ(String[] strArr, Activity activity, boolean z, int i) {
        if (VERSION.SDK_INT < 23) {
            return false;
        }
        if (epz.ॱ(strArr)) {
            bqx.ˊ("CameraChecker", "requestCode=" + i + " , no match permission check");
            return false;
        }
        boolean z2;
        for (String checkSelfPermission : strArr) {
            if (-1 == activity.checkSelfPermission(checkSelfPermission)) {
                z2 = true;
                break;
            }
        }
        z2 = false;
        if (!z2) {
            return false;
        }
        if (z) {
            activity.requestPermissions(strArr, i);
        }
        return true;
    }
}
